var RenYuan = new Vue({

    el : '#Xingweirendinglist',
    data :{

        deptid:'',
        truename:'',
        jiashu:{},
        renyuan:{},
        danweinamelist:[],
        renyuanList:[],
        xiangqingList:[],


        editFlag : 0,					// 0:新增，1：修改
        show : false,					// 显示列表是否有数据

        pageIndex : 1,
        pageSize :6,
        pageCount : 0,
        recordCount : 0,
        inputPageIndexValue : "",


    },
    created : function() {

        this.findVaild(0);
        this.selectDepNameByValid();


    },
    methods : {

        selectDepNameByValid : function() {
            var _this = this;

            // 单位名称
            $.post("../dept/findcengji_by_deptid", {
                deptid: 0,
                rdm : Math.random()
            }, function (ppData) {
                if (ppData != null) {
                    if (ppData.result == '1') {
                        var data = ppData.resultContent;
                        _this.danweinamelist = data;
                    } else {
                        layer.alert(ppData.message);
                    }
                }
            }, "json");
        },

        findVaild: function(ppFlag){
            var _this = this;
            if (ppFlag==1){
                _this.pageIndex=1;
            }
            layer.open({type:3});
            $.post("../zhenbieqingkuang/find_allrenyuan",{
                deptid : _this.deptid,
                truename: _this.truename,
                startindex : _this.pageIndex,
                pagesize : _this.pageSize,
                rdm : Math.random()
            },function(ppData){
                layer.closeAll("loading");
                if (ppData != null){
                    if(ppData.result == "1"){
                        var data=ppData.resultContent;

                        if(data.RenyuanList.length > 0){
                            _this.show = true;
                            _this.renyuanList=data.RenyuanList;

                            var PageInfo = data.PageInfo;
                            _this.pageIndex = PageInfo.pageIndex;
                            _this.recordCount = PageInfo.recordCount;
                            _this.pageCount = PageInfo.pageCount;

                        }else {
                            _this.show = false;
                        }

                    }else{
                        layer.alert(ppData.message);
                    }
                }

            },"json");
        },

        ShowRending: function(ppRenyuan){
            var _this = this;
            $("#rendingModal").modal();
            _this.renyuan = ppRenyuan;
            _this.findJiashu();
            _this.findZhenbiexiangqing();
        },

        findJiashu: function(){
            var _this = this;
            layer.open({type:3});
            $.post("../zhenbieqingkuang/find_alljiashu_by_renyuan",{
                renyuanid : _this.renyuan.renyuanid,
                rdm : Math.random()
            },function(ppData){
                layer.closeAll("loading");
                if (ppData != null){
                    if(ppData.result == "1"){
                        var data=ppData.resultContent;

                        if(data!=null){
                            _this.jiashu=data;
                        }

                    }else{
                        layer.alert(ppData.message);
                    }
                }

            },"json");
        },

        findZhenbiexiangqing: function(){
            var _this = this;
            layer.open({type:3});
            $.post("../zhenbieqingkuang/find_zhenbiexiangqing_by_renyuanid",{
                renyuanid : _this.renyuan.renyuanid,
                rdm : Math.random()
            },function(ppData){
                layer.closeAll("loading");
                if (ppData != null){
                    if(ppData.result == "1"){
                        var data=ppData.resultContent;

                        if(data.length>0){
                            _this.xiangqingList=data;
                        }

                    }else{
                        layer.alert(ppData.message);
                    }
                }

            },"json");
        },

        Daochu: function(){
            var _this = this;
            window.open("../zhenbieqingkuang/daochu?renyuanid="+_this.renyuan.renyuanid);

        },


        //跳到首页
        SetPageIndex : function(){
            this.pageIndex = 1;
        },
        SetPageEnd : function(){
            this.pageIndex = this.pageCount;
        },
        //上一页
        SetPageIndexPrePage : function(){
            var PrePage = ((this.pageIndex -1) <= 0) ? 1 : (this.pageIndex -1);
            this.pageIndex = PrePage;
        },
        //下一页
        SetPageIndexNextPage : function(){
            var NextPage = ((this.pageIndex +1) >= this.pageCount) ? this.pageCount : (this.pageIndex +1);
            this.pageIndex = NextPage;
        },
        //跳转界面
        JumpPage : function(){
            if(this.inputPageIndexValue <= 1){
                this.inputPageIndexValue = 1;
            }else if(this.inputPageIndexValue >= this.pageCount){
                this.inputPageIndexValue = this.pageCount;
            }
            this.pageIndex = this.inputPageIndexValue;
            this.inputPageIndexValue = '';
        },




    },
    watch :{
        //监控分页情况，刷新列表
        pageIndex : function(){

            this.findVaild(0);
        }
    }

});
